var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, o) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var o in e)
              Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          })(e, o);
      };
      return function (e, o) {
        function i() {
          this.constructor = e;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        t(e, o),
          (e.prototype =
            null === o
              ? Object.create(o)
              : ((i.prototype = o.prototype), new i()));
      };
    })(),
  AXNoticeBoardView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        (e.spaceTime = 0),
        (e.onLoadNoticeBoardViewDataFn = {
          caller: e,
          code: 90,
          method: function (t) {
            if (e.currentPage >= 1) {
              if (0 == t.list.length) return void e.currentPage--;
              for (n = 0; n < t.list.length; n++) {
                var o = t.list[n];
                e.noticeArr.push(o), (e.dataSource = []);
              }
            } else (e.noticeArr = t.list), (e.dataSource = []);
            e.noticeArr.length > 0 && (e.list_noticeBoard.visible = !0),
              (e.isloading = !1),
              (e.noticeArr = t.list),
              (e.list_noticeBoard.visible = !0);
            var i;
            e.dataSource = [];
            for (var n = 0; n < e.noticeArr.length; n++) {
              var r = e.noticeArr[n];
              console.log(r.state),
                (i = {
                  label_notice_title: { text: r.title },
                  label_notice_time: { text: e.getDateDiff(r.createTime) },
                  image_notice_states: { skin: e.iconWithState(r.state) },
                }),
                e.dataSource.push(i);
            }
            e.list_noticeBoard.dataSource = e.dataSource;
          },
        }),
        e.btn_noticeBoard.on(Laya.Event.CLICK, e, e.onBoardClose),
        WebSocketService.addListener(e.onLoadNoticeBoardViewDataFn),
        (e.list_noticeBoard.vScrollBarSkin = ""),
        (e.list_noticeBoard.selectEnable = !0),
        e.list_noticeBoard.on(
          Laya.Event.CLICK,
          e,
          e.onDidClickNoticeBoardDataFn
        ),
        (e.list_noticeBoard.scrollBar.changeHandler = new Handler(
          e,
          e.onLoadMoreData
        )),
        e
      );
    }
    return (
      __extends(e, t),
      (e.openView = function () {
        return (
          null == this.noticeBoardVC && (this.noticeBoardVC = new e()),
          (this.noticeBoardVC.list_noticeBoard.visible = !1),
          (this.noticeBoardVC.currentPage = 0),
          WebSocketService.send({ c: 90, d: { pageNum: 0 } }),
          this.noticeBoardVC
        );
      }),
      (e.prototype.onLoadMoreData = function (t) {
        var e = t / this.list_noticeBoard.scrollBar.max,
          o = new Date(),
          i = !1;
        if (
          (o.getTime() - this.spaceTime >= 3e3 && (i = !0),
          1 == e && 0 == this.isloading && i)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            WebSocketService.send({ c: 90, d: { pageNum: this.currentPage } }),
            void (this.spaceTime = o.getTime())
          );
      }),
      (e.prototype.onDidClickNoticeBoardDataFn = function (t) {
        if ("" != t.target.name) {
          var e = this.noticeArr[this.list_noticeBoard.selectedIndex],
            o =
              (this.noticeArr[this.list_noticeBoard.selectedIndex].content,
              this.noticeArr[this.list_noticeBoard.selectedIndex].title,
              new NoticeBoardDetailView(e));
          o.pos(0, 35), Laya.stage.addChild(o);
        }
      }),
      (e.prototype.iconWithState = function (t) {
        return 1 == t
          ? "comp/Home/image_xinxinxin.png"
          : "comp/Home/image_dingdingding.png";
      }),
      (e.prototype.getDateDiff = function (t) {
        var e = t;
        e = (e = e.substring(0, 19)).replace(/-/g, "/");
        var o = new Date(e).getTime(),
          i = new Date().getTime() - o,
          n = i / 2592e6,
          r = i / 6048e5,
          a = i / 864e5,
          c = i / 36e5,
          s = i / 6e4;
        return n >= 1
          ? Math.floor(n) + "月前"
          : r >= 1
          ? Math.floor(r) + "周前"
          : c >= 12
          ? Math.floor(a) + "天前"
          : c >= 1
          ? Math.floor(c) + "个小时前"
          : s >= 1
          ? Math.floor(s) + "分钟前"
          : "刚刚发表";
      }),
      (e.prototype.onBoardClose = function () {
        this.removeSelf();
      }),
      e
    );
  })(ui.NoticeBoardController.AXNoticeBoardViewUI);
